<template>
	<view class="container">
		<view class="banner">
			 <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" :duration="duration" easing-function="easeOutCubic" circular>
				<swiper-item v-for="(item,i) in bgUrl" :key='i'>
					<view class="swiper-item uni-bg-red"><image :src="item" mode="" class="bg" show-menu-by-longpress></image></view>
				</swiper-item>
			</swiper>
		</view>
		<view class="content">
			<view class="info">
				<view class="integral_section" @tap="integrals">
					<view class="top">
						<text class="title">我的积分</text>
						<text class="value">{{  isLogin ? member.pointNum : 0 }}</text>
					</view>
					<view class="bottom">
						进入积分商城
						<view class="iconfont iconarrow-right"></view>
					</view>
				</view>
				<view class="qrcode_section" @tap="memberCode">
					<image src="/static/images/index/qrcode.png"></image>
					<text class="title">会员码</text>
				</view>
			</view>
			<view class="buy-type">
				<view class="entrance">
					<view class="item" @tap="takein">
						<image src="/static/images/index/md.png" class="icon"></image>
						<view class="title">自取</view>
					</view>
				</view>
				<view class="entrance entrance-nop">
					
				</view>
				<view class="entrance">
					<view class="item" @tap="takeout">
						<image src="/static/images/index/wm.png" class="icon"></image>
						<view class="title">外卖</view>
					</view>
				</view>
			</view>
			<view class="member-news">
				<view class="entrancetwo">
					<view class="item" @tap="goVip">
						<image src="/static/images/index/vip.png" class="icon"></image>
						<view class="title" v-if="!isLogin">开通会员</view>
						<view class="title" v-if="member.svip && !member.vip">svip</view>
						<view class="title" v-if="member.vip && !member.svip">vip</view>
						<view class="title" v-if="member.vip && member.svip">svip+</view>
						<view class="title" v-if="isLogin && !member.svip && !member.vip">开通会员</view>
					</view>
				</view>
				<view class="entrancetwo">
					<view class="item" @tap="packages">
						<image src="/static/images/index/yhq.png" class="icon"></image>
						<view class="title">来场约惠</view>
					</view>
				</view>
			</view>
			<view class="member-news">
				<view class="entrancetwo">
					<view class="item" @tap="integrals">
						<image src="/static/images/index/jf.png" class="icon"></image>
						<view class="title">积分商城</view>
					</view>
				</view>
				<view class="entrancetwo">
					<view class="item" @tap="noAction">
						<image src="/static/images/index/my.png" class="icon"></image>
						<view class="title">加盟开店</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 加载弹窗 -->
		<view class="shade" v-if="showShade && (!member.svip && !member.vip)">
			<image src="../../static/images/vip.png" mode="" class="vip"></image>
			<view class="cancle" @tap="cancle()"></view>
			<view class="govip" @tap="goVip()"></view>
		</view>
	</view>
</template>

<script>
	import {mapState, mapGetters} from 'vuex'
	
	export default {
		data() {
			return {
				bgUrl:[],
				couponUrl:'',
				indicatorDots: true,
				autoplay: true,
				interval: 6000,
				duration: 500,
				showShade:true
			}
		},
		computed: {
			...mapState(['member']),
			...mapGetters(['isLogin'])
		},
		onShow() {
			this.$http.get('sys/config', {params: {}}).then(res => {
				this.bgUrl = res.data.data.bg_img
				this.couponUrl = res.data.data.coupon_img
				
			}).catch(err => {
			
			})
		},
		methods: {
			takein() {
				this.$store.commit('SET_ORDER_TYPE', 'takein')
				uni.switchTab({
					url: '/pages/menu/menu'
				})
			},
			takeout() {
				if(!this.isLogin) {
					uni.navigateTo({url: '/pages/login/login'})
					return
				}
				uni.navigateTo({
					url: "/pages/address/address?is_choose=true"	
				})
			},
			integrals() {
				if(!this.isLogin) {
					uni.navigateTo({url: '/pages/login/login'})
					return
				}
				uni.navigateTo({
					url: '/pages/integrals/integrals'
				})
			},
			packages() {
				uni.navigateTo({
					url: '/pages/packages/index'
				})
			},
			memberCode() {
				if(!this.isLogin) {
					uni.navigateTo({url: '/pages/login/login'})
					return
				}
				uni.navigateTo({
					url: '/pages/mine/member-code'
				})
			},
			invite() {
				uni.navigateTo({
					url: '/pages/activities/invite'
				})
			},
			noAction(){
				uni.showToast({
					icon:'none',
					title:'未开通！'
				})
			},
			goVip(){
				this.showShade = false
				uni.navigateTo({
					url: '/pages/mine/vip'
				})
			},
			cancle(){
				this.showShade = false
			}
		}
	}
</script>

<style lang="scss" scoped>
/* #ifdef H5 */
page {
	height: auto;
	min-height: 100%;
}
/* #endif */

.banner {
	position: relative;
	width: 100%;
	height: 600rpx;
	.swiper{
		height: 600rpx;
	}
	.bg {
		width: 100%;
		height: 600rpx;
	}
	
	.intro {
		position: absolute;
		top: calc(50rpx + var(--status-bar-height));
		left: 40rpx;
		color: #FFFFFF;
		display: flex;
		flex-direction: column;
		
		.greet {
			font-size: $font-size-lg;
			margin-bottom: 10rpx;
		}
		
		.note {
			font-size: $font-size-sm;
		}
	}
}

.content {
	padding: 0 30rpx;
}
.buy-type{
	display: flex;
	align-items: center;
	justify-content: space-around;
	.entrance {
		position: relative;
		margin-bottom: 30rpx;
		border-radius: 10rpx;
		background-color: #ffffff;
		box-shadow: $box-shadow;
		padding: 60rpx 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
		.item {
			flex: 1;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			
			&:nth-child(1):after {
				position: absolute;
				width: 1rpx;
				background-color: #ddd;
				right: 0;
				height: 100%;
				transform: scaleX(0.5) scaleY(0.8);
			}
			
			.icon {
				width: 84rpx;
				height: 84rpx;
				margin: 20rpx;
			}
			
			.title {
				font-size: 30rpx;
				color: $text-color-base;
				font-weight: 600;
			}
		}
	}
	.entrance-nop{
		padding: 14rpx;
		background-color: #F1F8FA;
	}
}
.entrancetwo {
	position: relative;
	margin-bottom: 30rpx;
	border-radius: 10rpx;
	background-color: #ffffff;
	box-shadow: $box-shadow;
	padding: 30rpx 0;
	display: flex;
	align-items: center;
	justify-content: center;
	
	.item {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: relative;
		
		&:nth-child(1):after {
			position: absolute;
			width: 1rpx;
			background-color: #ddd;
			right: 0;
			height: 100%;
			transform: scaleX(0.5) scaleY(0.8);
		}
		
		.icon {
			width: 84rpx;
			height: 84rpx;
			margin: 20rpx;
		}
		
		.title {
			font-size: 30rpx;
			color: $text-color-base;
			font-weight: 600;
		}
	}
}

.info {
	position: relative;
	margin-bottom: 30rpx;
	border-radius: 10rpx;
	background-color: #ffffff;
	box-shadow: $box-shadow;
	padding: 30rpx;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-top: 30rpx;
	
	.integral_section {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		
		.top {
			display: flex;
			align-items: center;
			
			.title {
				font-weight: 600;
				color: $text-color-base;
				font-size: $font-size-base;
				margin-right: 10rpx;
			}
			.value {
				font-size: 44rpx;
				font-weight: bold;
			}
		}
		
		.bottom {
			font-size: $font-size-sm;
			color: $text-color-assist;
			display: flex;
			align-items: center;
		}
	}
	
	.qrcode_section {
		color: $color-primary;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		font-size: $font-size-sm;
		.title {
			color: $text-color-base;
			font-size: $font-size-base;
		}
		image {
			width: 40rpx;
			height: 40rpx;
			margin-bottom: 10rpx;
		}
	}
}

.navigators {
	width: 100%;
	margin-bottom: 20rpx;	
	border-radius: 10rpx;
	background-color: #ffffff;
	box-shadow: $box-shadow;
	padding: 20rpx;
	display: flex;
	align-items: stretch;
	
	.left {
		width: 340rpx;
		margin-right: 20rpx;
		display: flex;
		padding: 0 20rpx;
		flex-direction: column;
		font-size: $font-size-sm;
		color: $text-color-base;
		background-color: #F2F2E6;
		
		.grid {
			height: 50%;
			display: flex;
		}
	}
	
	.right {
		width: 290rpx;
		display: flex;
		flex-direction: column;
		
		.tea-activity, .member-gifts {
			width: 100%;
			display: flex;
			padding: 20rpx;
			font-size: $font-size-sm;
			color: $text-color-base;
			align-items: center;
			position: relative;
		}
		
		.tea-activity {
			background-color: #FDF3F2;
			margin-bottom: 20rpx;
		}
		
		.member-gifts {
			background-color: #FCF6D4;
		}
		
		.right-img {
			flex: 1;
			position: relative;
			margin-left: 20rpx;
			margin-right: -20rpx;
			margin-bottom: -20rpx;
			display: flex;
			align-items: flex-end;
			
			image {
				width: 100%;
			}
		}
	}
	
	.mark-img {
		width: 30rpx;
		height: 30rpx;
		margin-right: 10rpx;
	}
	
	.yzclh-img {
		height: 122.96rpx;
		width: 214.86rpx;
	}
}

.member-news {
	display: flex;
	justify-content: space-between;
	// margin-bottom: 30rpx;
	.item {
		flex: 1;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		position: relative;
		width: 326rpx;
		
		&:nth-child(1):after {
			position: absolute;
			width: 1rpx;
			background-color: #ddd;
			right: 0;
			height: 100%;
			transform: scaleX(0.5) scaleY(0.8);
		}
		
		.icon {
			width: 84rpx;
			height: 84rpx;
			margin: 20rpx;
		}
		
		.title {
			font-size: 30rpx;
			color: $text-color-base;
			font-weight: 600;
		}
	}
}
.shade{
	width: 100%;
	height: 100%;
	background: #eee;
	position: fixed;
	top: 0;
	background: rgba(0, 0, 0, .5);
	.vip{
		position: fixed;
		margin: 0 auto;
		top: 33%;
		display: block;
		left: 10%;
		width: 600rpx;
		height: 500rpx;
	}
	.cancle{
		width: 200rpx;
		height: 80rpx;
		// background: red;
		position: fixed;
		top: 61%;
		left: 20%;
	}
	.govip{
		width: 200rpx;
		height: 80rpx;
		// background: red;
		position: fixed;
		top: 61%;
		left: 56%;
	}
}

</style>
